{extend name="template/base_default"}
{block name="header"}
<link rel="stylesheet" href="__CSS__/common.css">
<link rel="stylesheet" href="__CSS__/weui.min.css">
<link rel="stylesheet" href="__CSS__/index.css">
<link rel="stylesheet" href="__CSS__/weuix.min.css"/>
<script src="__JS__/zepto.min.js"></script>
<script src="__JS__/lrz.min.js"></script>
<style>

    .form-head{
        color: #545454;
        font-size: 16px;
        background-color: white;
        border-radius: 5px;
        overflow: hidden;
    }
    body{
        background-image:url("__IMG__/bj.png");
        background-size:cover;
        text-align: center;
    }
    .body-input{
        outline: none;
        color: #dddddd;
        position: relative;
        border: solid 1px #ffffff;
        background-color: rgba(255, 255, 255, 0);
        float: left;
        margin: auto;
        font-size: 16px;
        height: 41px;
        line-height: 41px;
        border-radius: 5px;
        width: 60%;
        font-family: "Microsoft YaHei UI";
    }
    .bottom-btn{
        width:50%;
        height:100%;
        float: left;
    }
    button{
        border: none;
        color:white;
    }
    .botton1{
        background-color: #FF0000;
    }
    .botton2{
        background-color: #131a34;
    }
    .input-window{

        opacity:0.3;/*其他，透明度50%*/
        filter:alpha(opacity=30);
        background-color: white;
        height:110px;
        width:110px;
        border-radius: 10px;
        margin-top: 30px;
    }
    .aa{
        height:3px;
        background-color: white;
        width:40px;
        position:absolute;
        top: 30px;
        left:55px;
    }
    .bb{
        width: 100%;
        height: 100%;
        opacity: 0;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
    .nav_bar{
        height:62px;
        background-color: #121832;
        width:100%;
        color:white;
        position:fixed;
        bottom: 0;
    }
    .nav_bar ul{
        width:32%;
        float: left;
        text-align: center;
        color:blue;
        margin-top: 10px;
        color:white;
    }
    .nav_bar ul li img{
        width:16px;
        height:16px;
        color:white;
    }
    li{
        list-style: none;
    }
    .erweima{
        width:200px;
        height:200px;
        margin-bottom: 20px;
    }
    .head{
        float:left;
        width:30px;
        height:30px;
    }
    .name{
        float:left;
        margin-left: 10px;
    }
    .big{
        margin-top:20px;
        margin-left: 20px;
    }
    .tuijian{
        margin-top: 16px;
        text-align: left;
        margin-left: 20px;
    }
    .form-head ul{
        float: left;
        height:90%;
        width:46%;
        margin-top: 8px;
        margin-left: 8px;
    }
    .form-head ul img{
        width:80px;
        height:80px;
    }
    .box9{
        background-color: white;
        width:32.6%;
        background-color: white;
        border: solid 1px #545454;
        height:120px;
        float: left;
        text-align:center ;
    }
    .box9 ul{
        margin-top: 10px;
    }
    .into{
        width:50%;
        margin-top: 40px;
    }
    .url{
        width:70%;
        overflow: hidden;
        margin-left: 20px;
    }
</style>
<script>
//    window.onload = function is_weixin(){
//        var ua = navigator.userAgent.toLowerCase();
//        if(ua.match(/MicroMessenger/i)=="micromessenger") {
//            var nav_bar = document.getElementById("nav_bar");
//            nav_bar.style.display = 'block';
//            return true;
//        } else {
//            var nav_bar = document.getElementById("nav_bar");
//            nav_bar.style.display = 'none';
//            return false;
//        }
//    }
</script>
{/block}
{block name="body"}


<div class="form-head" style="height:360px;margin-top:10px;width:90%;margin-left: auto;margin-right: auto">
    <div class="big">
        {empty name ="seller_info.logo"}
        <img class="head" src="__IMG__/che.png">
        {else/}
        <img class="head" src="__BASE__/index.php/picture/index?id={$seller_info.logo}">
        {/empty}

        <div class="name">{$seller_info.name}</div>

    </div><br>
    <p class="tuijian">推荐码：{$invite_code}</p>
    <div class="two-code">
        <p></p>
        <div id="qrcodeid" class="two-code-erweima-img" style="display: none;margin-top: 20px"></div>
        <div id="qrcode" style="margin-top: 30px"> </div>
    </div>
</div>





{/block}
{block name="footer"}
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript" src="__CDN__/jquery-qrcode/v1.0/jquery.qrcode.min.js"></script>
<script type="text/javascript" src="__JS__/public.js"></script>
<script>
    function copyUrl2(){
        var url = document.getElementById("url").value;
        window.clipboardData.setData("Text",url);
        alert("复制链接成功！");
    }


    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: "{$SignPackage['appId']}", // 必填，公众号的唯一标识
        timestamp:"{$SignPackage['timestamp']}" , // 必填，生成签名的时间戳
        nonceStr: "{$SignPackage['nonceStr']}", // 必填，生成签名的随机串
        signature: "{$SignPackage['signature']}",// 必填，签名，见附录1
        jsApiList: ['scanQRCode','closeWindow','onMenuShareTimeline','scanQRCode','onMenuShareAppMessage','onMenuShareQQ','getLocation','openLocation'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });

    wx.ready(function(){
        wx.onMenuShareTimeline({
            title: '有车有宝', // 分享标题
            link: "{$url}",
            imgUrl: "__IMG__/che.png", // 分享图标
            success: function () {
                // 用户确认分享后执行的回调函数
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });
        wx.onMenuShareAppMessage({
            title: '有车有宝', // 分享标题
            desc: '被我推荐为有车有宝会员', // 分享描述
            link: "{$url}", // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
            imgUrl: "__IMG__/che.png", // 分享图标
            type: '', // 分享类型,music、video或link，不填默认为link
            dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
            success: function () {
                // 用户确认分享后执行的回调函数
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });
    });
    $('#ewm').click(function () {
        wx.scanQRCode({
            needResult: 0,
            scanType: ["qrCode","barCode"],
            success: function (res) {
                var result = res.resultStr;
            }
        });
    })

    function utf16to8(str) { //解决中文乱码
        var out, i, len, c;
        out = "";
        len = str.length;
        for(i = 0; i < len; i++) {
            c = str.charCodeAt(i);
            if ((c >= 0x0001) && (c <= 0x007F)) {
                out += str.charAt(i);
            } else if (c > 0x07FF) {
                out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
                out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
            } else {
                out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
            }
        }
        return out;
    }
    //此处生成名片二维码（如要生成普通链接二维码 则 “text”参数值 直接替换成普通链接即可）
    var the_text = '{$url}';

    the_text = utf16to8(the_text);
    jQuery('#qrcodeid').qrcode({
        width:200,
        height:200,
        render:"canvas", //设置渲染方式 table canvas
        typeNumber : -1,  //计算模式
        correctLevel  : 0,//纠错等级
        background   : "#ffffff",//背景颜色
        foreground   : "#000000",//前景颜色
        text:the_text
    });

    function convertCanvasToImage(canvas) {
        //新Image对象，可以理解为DOM
        var image = new Image();
        // canvas.toDataURL 返回的是一串Base64编码的URL，当然,浏览器自己肯定支持
        // 指定格式 PNG
        image.src = canvas.toDataURL("image/png");
        return image;
    }

    //获取网页中的canvas对象

    var mycanvas1=document.getElementsByTagName('canvas')[0];

    //将转换后的img标签插入到html中

    var img=convertCanvasToImage(mycanvas1);

    $('#qrcode').append(img);
</script>
{/block}